import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_app2/routers/application.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:url_launcher/url_launcher.dart';

import '../service/service_method.dart';

class HomePage extends StatefulWidget {
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>
    with AutomaticKeepAliveClientMixin {
  int page = 1;
  List<Map> hotGoodsList = [];

  @override
  bool get wantKeepAlive => true;

  @override
  void initState() {
    super.initState();
  }

  GlobalKey<EasyRefreshState> _easyRefreshKey =
      new GlobalKey<EasyRefreshState>();
  GlobalKey<RefreshFooterState> _footerKey =
      new GlobalKey<RefreshFooterState>();

  @override
  Widget build(BuildContext context) {
    super.build(context);
    var formData = {'lon': '115.02932', 'lat': '35.76189'};
    return Scaffold(
        backgroundColor: Color.fromRGBO(244, 245, 245, 1.0),
        appBar: AppBar(
          title: Text('百姓生活+'),
          centerTitle: true,
        ),
        body: FutureBuilder(
          future: request('homePageContext', formData: formData),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              var data = json.decode(snapshot.data.toString());
              List<Map> swiperDataList =
                  (data['data']['slides'] as List).cast(); // 顶部轮播组件数
              List<Map> navigatorList =
                  (data['data']['category'] as List).cast(); //类别列表
              String advertesPicture =
                  data['data']['advertesPicture']['PICTURE_ADDRESS']; //广告图片

              String leaderImage =
                  data['data']['shopInfo']['leaderImage']; //店长图片
              String leaderPhone =
                  data['data']['shopInfo']['leaderPhone']; //店长电话
              List<Map> recommendList =
                  (data['data']['recommend'] as List).cast(); // 商品推荐
              String floor1Title =
                  data['data']['floor1Pic']['PICTURE_ADDRESS']; //楼层1的标题图片
              String floor2Title =
                  data['data']['floor2Pic']['PICTURE_ADDRESS']; //楼层1的标题图片
              String floor3Title =
                  data['data']['floor3Pic']['PICTURE_ADDRESS']; //楼层1的标题图片
              List<Map> floor1 =
                  (data['data']['floor1'] as List).cast(); //楼层1商品和图片
              List<Map> floor2 =
                  (data['data']['floor2'] as List).cast(); //楼层1商品和图片
              List<Map> floor3 =
                  (data['data']['floor3'] as List).cast(); //楼层1商品和图片

              return EasyRefresh(
                refreshFooter: ClassicsFooter(
                    key: _footerKey,
                    bgColor: Colors.white,
                    textColor: Colors.pink,
                    moreInfoColor: Colors.pink,
                    showMore: true,
                    noMoreText: '',
                    moreInfo: '加载中',
                    loadReadyText: '上拉加载....'),
                child: ListView(
                  children: <Widget>[
                    SwiperDiy(swiperDataList: swiperDataList), //页面顶部轮播组件
                    TopNavigator(navigatorList: navigatorList), //导航组件
                    AdBanner(advertesPicture: advertesPicture),
                    LeaderPhone(
                        leaderImage: leaderImage,
                        leaderPhone: leaderPhone), //广告组件
                    Recommend(recommendList: recommendList),
                    FloorTitle(picture_address: floor1Title),
                    FloorContent(floorGoodsList: floor1),
                    FloorTitle(picture_address: floor2Title),
                    FloorContent(floorGoodsList: floor2),
                    FloorTitle(picture_address: floor3Title),
                    FloorContent(floorGoodsList: floor3),
                    _hotGoods(),
                  ],
                ),
                loadMore: () async {
                  print('开始加载更多');
                  var formPage = {'page': page};
                  await request('homePageBelowConten', formData: formPage)
                      .then((val) {
                    var data = json.decode(val.toString());
                    List<Map> newGoodsList = (data['data'] as List).cast();
                    setState(() {
                      hotGoodsList.addAll(newGoodsList);
                      page++;
                    });
                  });
                },
              );
            } else {
              return Center(
                child: CircularProgressIndicator(
                  strokeWidth: 4.0,
                ),
              );
            }
          },
        ));
  }

  //火爆商品接口
  void _getHotGoods() {
    var formPage = {'page': page};
    request('homePageBelowConten', formData: formPage).then((val) {
      var data = json.decode(val.toString());
      List<Map> newGoodsList = (data['data'] as List).cast();
      setState(() {
        hotGoodsList.addAll(newGoodsList);
        page++;
      });
    });
  }

  //火爆专区标题
  Widget hotTitle = Container(
    margin: EdgeInsets.only(top: 10.0),
    padding: EdgeInsets.all(5.0),
    alignment: Alignment.center,
    decoration: BoxDecoration(
        color: Colors.white,
        border: Border(bottom: BorderSide(width: 0.5, color: Colors.black12))),
    child: Text('火爆专区'),
  );

  //火爆专区子项
  Widget _wrapList() {
    if (hotGoodsList.length != 0) {
      List<Widget> listWidget = hotGoodsList.map((val) {
        return InkWell(
            onTap: () {
              Application.router
                  .navigateTo(context, "/detail?id=${val['goodsId']}");
            },
            child: Container(
              width: ScreenUtil().setWidth(372),
              color: Colors.white,
              padding: EdgeInsets.all(5.0),
              margin: EdgeInsets.only(bottom: 3.0),
              child: Column(
                children: <Widget>[
                  Image.network(
                    val['image'],
                    width: ScreenUtil().setWidth(375),
                  ),
                  Text(
                    val['name'],
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        color: Colors.pink, fontSize: ScreenUtil().setSp(26)),
                  ),
                  Row(
                    children: <Widget>[
                      Text('￥${val['mallPrice']}'),
                      Text(
                        '￥${val['price']}',
                        style: TextStyle(
                            color: Colors.black26,
                            decoration: TextDecoration.lineThrough),
                      )
                    ],
                  )
                ],
              ),
            ));
      }).toList();

      return Wrap(
        spacing: 2,
        children: listWidget,
      );
    } else {
      return Text(' ');
    }
  }

  //火爆专区组合
  Widget _hotGoods() {
    return Container(
        child: Column(
      children: <Widget>[
        hotTitle,
        _wrapList(),
      ],
    ));
  }
}

// 首页轮播组件编写
class SwiperDiy extends StatelessWidget {
  final List swiperDataList;
  SwiperDiy({Key key, this.swiperDataList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      height: ScreenUtil().setHeight(333),
      width: ScreenUtil().setWidth(750),
      child: Swiper(
        itemBuilder: (BuildContext context, int index) {
          return InkWell(
            onTap: () {
              Application.router.navigateTo(
                  context, "/detail?id=${swiperDataList[index]['goodsId']}");
            },
            child: Image.network("${swiperDataList[index]['image']}",
                fit: BoxFit.fill),
          );
        },
        itemCount: swiperDataList.length,
        pagination: new SwiperPagination(),
        autoplay: true,
      ),
    );
  }
}

//首页导航组件
class TopNavigator extends StatelessWidget {
  final List navigatorList;
  TopNavigator({Key key, this.navigatorList}) : super(key: key);
  Widget _gridViewItemUI(BuildContext context, item) {
    return InkWell(
      onTap: () {
        print('点击了导航');
      },
      child: Column(
        children: <Widget>[
          Image.network(item['image'], width: ScreenUtil().setWidth(95)),
          Text(item['mallCategoryName'])
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    if (navigatorList.length > 10) {
      navigatorList.removeRange(10, navigatorList.length);
    }
    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: 5.0),
      height: ScreenUtil().setHeight(320),
      padding: EdgeInsets.all(3.0),
      child: GridView.count(
        physics: NeverScrollableScrollPhysics(),
        crossAxisCount: 5,
        padding: EdgeInsets.all(4.0),
        children: navigatorList.map((item) {
          return _gridViewItemUI(context, item);
        }).toList(),
      ),
    );
  }
}

//广告图片
class AdBanner extends StatelessWidget {
  final String advertesPicture;

  AdBanner({Key key, this.advertesPicture}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 5.0),
      color: Colors.white,
      child: Image.network(advertesPicture),
    );
  }
}

class LeaderPhone extends StatelessWidget {
  final String leaderImage; //店长图片
  final String leaderPhone; //店长电话

  LeaderPhone({Key key, this.leaderImage, this.leaderPhone}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: InkWell(
        onTap: _launchURL,
        child: Image.network(leaderImage),
      ),
    );
  }

  void _launchURL() async {
    String url = 'tel:' + leaderPhone;
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }
}

//商品推荐
class Recommend extends StatelessWidget {
  final List recommendList;

  Recommend({Key key, this.recommendList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 10.0),
      child: Column(
        children: <Widget>[_titleWidget(), _recommedList()],
      ),
    );
  }

//推荐商品标题
  Widget _titleWidget() {
    return Container(
        alignment: Alignment.centerLeft,
        padding: EdgeInsets.fromLTRB(10.0, 2.0, 0, 5.0),
        decoration: BoxDecoration(
            color: Colors.white,
            border:
                Border(bottom: BorderSide(width: 0.5, color: Colors.black12))),
        child: Text('商品推荐', style: TextStyle(color: Colors.pink)));
  }

  Widget _recommedList() {
    return Container(
      height: ScreenUtil().setHeight(350),
      child: ListView.builder(
        scrollDirection: Axis.horizontal,
        itemCount: recommendList.length,
        itemBuilder: (context, index) {
          return _item(context, index);
        },
      ),
    );
  }

  Widget _item(context, index) {
    return InkWell(
      onTap: () {
        Application.router.navigateTo(
            context, "/detail?id=${recommendList[index]['goodsId']}");
      },
      child: Container(
        height: ScreenUtil().setHeight(340),
        width: ScreenUtil().setWidth(280),
        padding: EdgeInsets.all(8.0),
        decoration: BoxDecoration(
            color: Colors.white,
            border:
                Border(left: BorderSide(width: 0.5, color: Colors.black12))),
        child: Column(
          children: <Widget>[
            Image.network(recommendList[index]['image']),
            Text('￥${recommendList[index]['mallPrice']}'),
            Text(
              '￥${recommendList[index]['price']}',
              style: TextStyle(
                  decoration: TextDecoration.lineThrough, color: Colors.grey),
            )
          ],
        ),
      ),
    );
  }
}

//楼层标题
class FloorTitle extends StatelessWidget {
  final String picture_address; // 图片地址
  FloorTitle({Key key, this.picture_address}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(8.0),
      child: Image.network(picture_address),
    );
  }
}

//楼层商品组件
class FloorContent extends StatelessWidget {
  final List floorGoodsList;

  FloorContent({Key key, this.floorGoodsList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[_firstRow(context), _otherGoods(context)],
      ),
    );
  }

  Widget _firstRow(context) {
    return Row(
      children: <Widget>[
        _goodsItem(context, floorGoodsList[0]),
        Column(
          children: <Widget>[
            _goodsItem(context, floorGoodsList[1]),
            _goodsItem(context, floorGoodsList[2]),
          ],
        )
      ],
    );
  }

  Widget _otherGoods(context) {
    return Row(
      children: <Widget>[
        _goodsItem(context, floorGoodsList[3]),
        _goodsItem(context, floorGoodsList[4]),
      ],
    );
  }

  Widget _goodsItem(BuildContext context, Map goods) {
    return Container(
      width: ScreenUtil().setWidth(375),
      child: InkWell(
        onTap: () {
//          print('点击了楼层商品');
          Application.router
              .navigateTo(context, "/detail?id=${goods['goodsId']}");
        },
        child: Image.network(goods['image']),
      ),
    );
  }
}

//import 'package:flutter/material.dart';
//// import 'package:dio/dio.dart';
//// import '../config/httpHeaders.dart';
//import '../service/service_method.dart';
//import 'package:flutter_swiper/flutter_swiper.dart';
//import 'dart:convert';  //json反编译
//import 'package:flutter_screenutil/flutter_screenutil.dart'; //flutter 屏幕适配方案
//import 'package:url_launcher/url_launcher.dart';
//
//class HomePage extends StatefulWidget {
//  _HomePageState createState() => _HomePageState();
//}
//
//class _HomePageState extends State<HomePage> {
//  //有了FutureBuilder，我们就没必要再用initState了
//  //String homePageContent='正在获取数据';
// // @override
//  // void initState() {
//  //   getHomePageContent().then((val){
//  //     setState(() {
//  //          homePageContent=val.toString();
//  //     });
//  //   });
//  //   super.initState();
//  // }
//
//  @override
//  Widget build(BuildContext context) {
//    return Scaffold(
//      appBar: AppBar(
//        title: Text('百姓生活+'),
//      ),
//      body:FutureBuilder(               //Flutter内置的组件很好的解决异步渲染的问题,用来等待异步请求的.使用FuturerBuilder来改造HomePage类里的build方法
//        future: getHomePageContent(),
//        builder: (context,snapshot){  //构造器接收上下文，异步请求
//          //数据处理
//          if(snapshot.hasData){       //判断是否有值
//            var data = json.decode(snapshot.data.toString()); //json转换成字符串
//            List<Map> swiperData  = (data['data']['slides'] as List).cast(); //给轮播组件的数据是外边是List里边是map(顶部轮播组件数)
//            List<Map>  navgatorList= (data['data']['category'] as List).cast(); //导航组件
//            String adPicture = data['data']['advertesPicture']['PICTURE_ADDRESS'];
//            String leaderImage = data['data']['shopInfo']['leaderImage'];
//            String leaderPhone = data['data']['shopInfo']['leaderPhone'];
//
//            return SingleChildScrollView( //纵向超出了边界，界面显示不下.是一个可以滚动的widget框，没有组件实体（就是你看不出什么UI界面来）
//              child: Column(
//                children: <Widget>[
//                  SwiperModule(swiperDataList: swiperData ), //页面顶部轮播组件
//                  TopNavigator(navgatorList:navgatorList),   //导航
//                  AdBanner(adPicture:adPicture),              //广告条
//                  LeaderPhone(leaderImage:leaderImage,leaderPhone:leaderPhone), //打电话
//                ],
//              )
//            );
//
//          }else{
//            return Center(
//              //child: Text('加载中...',fontSize:ScreenUtil().setSp(28,false)), //APP字体适配，不会与系统字体大小改变
//              child: Text('加载中...'), //点击底部导航页面切换后的等待
//            );
//          }
//        },
//      )
//    );
//  }
//}
//
////首页轮播组件(静态类)--自定义类供上面使用,也可以把这个组件单独新建一个文件保存再引入（利于项目分工），这里不做。
//class SwiperModule extends StatelessWidget {
//  final List swiperDataList; //SwiperModule类需要接受一个List参数
//  SwiperModule({Key key,this.swiperDataList}):super(key:key);  //官方推荐写法的构造函数
//  //SwiperModule({Key key,this.swiperDataList});
//
//  @override
//  Widget build(BuildContext context) {
//    //  ScreenUtil.instance=ScreenUtil(width: 750,height: 1334)..init(context); //正常一个项目初始化一遍就行，所以不放在这。放在index_page.dart
//    return Container(
//      //height: 200.0,  //控制container的高度，即要根据轮播图片的高度设置，但是为了适配不要写死
//      height: ScreenUtil().setHeight(333),  //屏幕适配
//      width: ScreenUtil().setWidth(750),
//      child: new Swiper(
//        itemBuilder:(BuildContext context,int index){ //flutter_swiper的构造器
//          return Image.network("${swiperDataList[index]['image']}",fit: BoxFit.fill);
//
//          //轮播图片数组,fit: BoxFit.fill--满容器填充.[index]['image']取对应索引下的json数组的image字段值
//          //flutter_swiper插件详见：https://github.com/best-flutter/flutter_swiper
//        },
//        itemCount: swiperDataList.length,
//        pagination: SwiperPagination(),
//        autoplay: true,
//      ),
//    );
//  }
//}
//
////首页导航:把导航拆开为Column和GridView，就不会产生太多的嵌套地狱
//class TopNavigator extends StatelessWidget {
//  final List navgatorList;
//
//  TopNavigator({Key key, this.navgatorList}) : super(key: key);
//
//  Widget _gridViewItemUI(BuildContext context , item){  //item为导航项
//    return InkWell(     //每个导航项都会跳转页面
//      onTap: (){print('点击了导航');},      //每个导航项的单击事件
//      child: Column(                      //子项
//        children: <Widget>[
//          Image.network(item['image'],width:ScreenUtil().setWidth(95)),
//          Text(item['mallCategoryName'])
//        ],
//      ),
//    );
//  }
//
//  @override
//  Widget build(BuildContext context) {
//     //发现界面多了一个类别，并不是我们想要的10个列表.解决的办法就是把List进行截取
//     if(this.navgatorList.length>10){
//       this.navgatorList.removeRange(10, this.navgatorList.length);
//     }
//    return Container(
//      height: ScreenUtil().setHeight(320),
//      padding: EdgeInsets.all(1.0),
//      child: GridView.count(    //
//        crossAxisCount: 5,      //一行有5个
//        padding: EdgeInsets.all(2.0),   //上下两行有一定距离
//        children: navgatorList.map((item){   //遍历,里面接收一个回调
//          return _gridViewItemUI(context, item);
//        }).toList(),
//
//      ),
//    );
//  }
//}
//
////广告条：为了以后变化很大单独做个组件（其实就是一张图片）
//class AdBanner extends StatelessWidget {
//  final String adPicture;
//
//  AdBanner({Key key, this.adPicture}) : super(key: key);
//
//  @override
//  Widget build(BuildContext context) {
//    return Container(
//      child: Image.network(adPicture)
//    );
//  }
//}
//
////一键拨打电话
//class LeaderPhone extends StatelessWidget {
//  final String leaderImage;  //图片
//  final String leaderPhone;  //电话号码
//
//  LeaderPhone({Key key, this.leaderImage,this.leaderPhone}) : super(key: key); //把两个值传递过来
//
//  @override
//  Widget build(BuildContext context) {
//    return Container(
//      child: InkWell(
//        onTap: _launchUrl,
//        child: Image.network(leaderImage),
//      )
//    );
//  }
//
//    void _launchUrl() async{
//    String url = 'tel:'+leaderPhone;
//    if(await canLaunch(url)){
//      await launch(url);
//    }else{
//      throw '找不到发射的URL';
//    }
//  }
//}
//
////商品展示
//class Recommend extends StatelessWidget {
//  final List recommendList;
//
//  Recommend({Key key, this.recommendList}) : super(key: key);
//
//  //使用内部组件制作自定义组件（我们商品展示是可以横向滚动的，把图片和商品价格分成两个组件）
//  //推荐商品标题
//  Widget _titleWidget(){
//    return Container(
//      alignment: Alignment.centerLeft,
//      padding: EdgeInsets.fromLTRB(10.0, 2.0, 0, 5.0),
//      decoration: BoxDecoration(
//        color: Colors.white,
//        border: Border(bottom: BorderSide(width: 0.5,color: Colors.black12))
//      ),
//      child: Text(
//        '商品推荐',
//        style: TextStyle(color: Colors.pink),
//      )
//    );
//  }
//
////推荐商品单独项
//Widget _item(index){
//  return InkWell(
//    onTap: (){},
//    child: Container(
//      height: ScreenUtil().setHeight(330),
//      width: ScreenUtil().setWidth(250),
//      padding: EdgeInsets.all(8.0),
//      decoration: BoxDecoration(
//        color: Colors.white,
//        border: Border(left: BorderSide(width: 0.5,color: Colors.black12))
//      ),
//      //每个商品里面是纵向排列，图片文字
//      child: Column(
//        children: <Widget>[
//          Image.network(recommendList[index]['image']),
//          Text('￥${recommendList[index]['mallPrice']}'),
//          Text(
//            '￥${recommendList[index]['price']}',
//            style: TextStyle(
//              decoration: TextDecoration.lineThrough,
//              color: Colors.grey
//            ),
//          ),
//        ],
//      ),
//    ),
//  );
//}
//
//
////横向列表组件(左右滑动)
//Widget _recommendList(){
//  return Container(
//    height: ScreenUtil().setHeight(330),
//    child: ListView.builder(
//      scrollDirection: Axis.horizontal,
//      itemCount: recommendList.length,
//      itemBuilder: (context,index){
//        return _item(index);
//      },
//    ),
//  );
//}
//
//
//  @override
//  Widget build(BuildContext context) {
//    return Container(
//      child: Container(
//        height: ScreenUtil().setHeight(380),
//        margin: EdgeInsets.only(top: 10.0),
//        child: Column(
//          children: <Widget>[
//            _titleWidget(),
//            _recommendList()
//          ],
//        ),
//      ),
//    );
//  }
//}
//
//
//
////加上请求头去get极客时间的首页数据
//// class HomePage extends StatefulWidget {
////   @override
////   _HomePageState createState() => _HomePageState();
//// }
//
//// class _HomePageState extends State<HomePage> {
////   String showText = '还没有请求数据';
//
////   @override
////   Widget build(BuildContext context) {
////     return Container(
////       child: Scaffold(
////         appBar: AppBar(title: Text('请求极客时间数据'),),
////         body: SingleChildScrollView(
////           child: Column(
////             children: <Widget>[
////               RaisedButton(
////                 onPressed: _jk,
////                 child: Text('请求数据'),
////               ),
////               Text(showText)
////             ],
////           ),
////         ),
////       ),
////     );
////   }
//
////   void _jk(){
////     print('开始请求......');
////     getHttp().then((val){
////       setState(() {
////         showText = val['data'].toString();
////       });
////     });
////   }
//
////   Future getHttp() async{
////     try {
////       Response response;
////       Dio dio = new Dio();
////       dio.options.headers= httpHeaders;
////       response =await dio.get('https://time.geekbang.org/serv/v1/column/newAll');
////       print(response);
////       return response.data;
////     } catch (e) {
////       return print(e);
////     }
////   }
//// }
//
//
////大保健例子--使用了easy mock做接口假数据
//// class HomePage extends StatefulWidget {
////   @override
////   _HomePageState createState() => _HomePageState();
//// }
//
//// class _HomePageState extends State<HomePage> {
////   TextEditingController typeController = TextEditingController();
////   String showText = '欢迎你来到美好人间包房';
////   @override
////   Widget build(BuildContext context) {
////     return Container(
////       child: Scaffold(
////         appBar: AppBar(
////           title: Text('美好人间'),),
////           body: SingleChildScrollView(
////             child: Container(
////             child: Column(
////               children: <Widget>[
////                 TextField(
////                   controller: typeController,
////                   decoration: InputDecoration(
////                     contentPadding: EdgeInsets.all(10.0),
////                     labelText: '美女类型',
////                     helperText: '请输入你喜欢的类型'
////                   ),
////                   autofocus: false, //避免打开键盘打乱布局
////                 ),
//
////                 RaisedButton(
////                   onPressed: _choiceAction,
////                   child: Text('选择完毕'),
////                 ),
////                 Text(
////                   showText,
////                   overflow: TextOverflow.ellipsis, //下面两行是兼容性，因为单独用text没有用container包裹
////                   maxLines: 1,
////                 )
////               ],
////             ),
////           ),
////           )
//
////       ),
////     );
////   }
//
////   void _choiceAction(){
////     print('开始选择你喜欢的类型...');
//
////     if(typeController.text.toString()==''){
////       showDialog(
////          context: context,
////         builder: (context)=>AlertDialog(title: Text('美女类型不为空'))
////       );
////     }else{
////       getHttp(typeController.text.toString()).then((val){
////         setState(() {
////                   showText = val['data']['name'].toString();
////                 });
////       });
////     }
////   }
//
////   Future getHttp(String TypeText) async{
////     try {
////       Response response;
////       var data = {'name':TypeText};
////       response = await Dio().post(
////         "https://www.easy-mock.com/mock/5c935c49b8b6271a46e8f9c3/example/dabaojian_post",
////         queryParameters: data
////       );
////       return response.data;
////     } catch (e) {
////       return print(e);
////     }
////   }
//
//
//// }
